﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="FisheryPlatform.Web.Admin.Product.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagName="Style" TagPrefix="Menu" Src="~/Modules/Menu/StyleMenu.ascx" %>
<%@ Register TagName="Left" TagPrefix="Menu" Src="~/Modules/Menu/LeftMenu.ascx" %>
<%@ Register TagName="Header" TagPrefix="Menu" Src="~/Modules/Menu/HeaderMenu.ascx" %>
<%@ Register TagName="Footer" TagPrefix="Menu" Src="~/Modules/Menu/FooterMenu.ascx" %>
<%@ Register TagName="PageBar" TagPrefix="ucPB" Src="~/Modules/PageBar.ascx" %>
<%@ Register TagName="ShareCode" TagPrefix="pl" Src="~/Modules/Layer/PopupLayer.ascx" %>
<%@ Import Namespace="FisheryPlatform.Bussiness.ShareCode" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <Menu:Style runat="server" ID="menuStyle" Title="Hi"></Menu:Style>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/calendar.js"></script>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/PagePromptBox.js"></script>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/PopupLayer.js"></script>
</head>
<body>
    <div class="wrapper">
        <Menu:Header runat="server" ID="menuHeader" />
        <div class="content">
            <Menu:Left runat="server" ID="menu_Left" />
            <div class="right">
                <div class="top">
                    信息管理>>所有信息</div>
                <div class="bottom">
                    <form id="form1" runat="server">
                    <div class="edit">
                        <dl style="margin-bottom:5px;">
                            <dt>信息编码：</dt><dd><input type="text" runat="server" id="txt_ProCode" class="txt_border txt_input1" /></dd>
                            <dt>标题：</dt>
                            <dd>
                                <input type="text" runat="server" id="txt_Title" class="txt_border txt_input1" /></dd>
                            <dt>发布时间：</dt>
                            <dd>
                                <input type="text" runat="server" size="10" id="txt_StartDate" onclick="calendar.show(this)"
                                    class="txt_border txt_input1" />-<input type="text" runat="server" id="txt_EndDate" size="10" onclick="calendar.show(this)"
                                    class="txt_border txt_input1" />
                                <label>
                                    [<a href="javascript:;" onclick="setDateToInputBy(3,0)">最近3天</a>&nbsp; <a href="javascript:;"
                                        onclick="setDateToInputBy(7,0)">最近1周</a>&nbsp; <a href="javascript:;" onclick="setDateToInputBy(1,1)">
                                            最近1月</a>]
                                </label>
                            </dd>
                            <dt>类别：</dt>
                            <dd>
                                <pl:ShareCode runat="server" ID="pl_Cate" DataType="Cate" />
                            </dd>
                            <dt>状态：</dt>
                            <dd>
                                <select id="sel_Status" runat="server">
                                    <option value="-1">全部</option>
                                    <option value="0">草稿</option>
                                    <option value="1">发布中</option>
                                    <option value="2">暂停</option>
                                </select></dd>
                            <dt>&nbsp;</dt>
                            <dd>
                                <input id="txt_PageIndex" type="hidden" runat="server" />
                                <input type="button" id="btn_Search" value="&nbsp;搜&nbsp;&nbsp;索&nbsp;" /></dd>
                        </dl>
                        <table class="list" cellspacing="0" cellpadding="0">
                            <tr>
                                <th style="width: 120px;">
                                    标题
                                </th>
                                <th style="width: 120px;">
                                    类别
                                </th>
                                <th style="width: 100px;">
                                    地区
                                </th>
                                <th style="width: 70px;">
                                    发布时间
                                </th>
                                <th style="width: 70px;">
                                    状态
                                </th>
                                <th style="width: 130px;">
                                    操作
                                </th>
                            </tr>
                            <% var index = 0;
                               foreach (var item in ProList)
                               {
                                   index++;
                            %>
                            <tr>
                                <td>
                                    <a href="Details.aspx?proId=<%=item.ProductId %>" target="_blank">
                                        <%=item.Title %></a>
                                </td>
                                <td>
                                    <%=HttpUtility.HtmlEncode(ShareCodeManager.GetShareCodeById(item.CategoryId).Name)%>
                                </td>
                                <td>
                                    <%=HttpUtility.HtmlEncode(ShareCodeManager.GetShareCodeById(item.AreaId).Name)%>
                                </td>
                                <td>
                                    <%=item.CreateDate.ToString() %>
                                </td>
                                <td>
                                    <%= GetProductStatus(item.Status) %>
                                </td>
                                <td>
                                    <a href="javascript:void(0);" onclick="productManager.setStatus(<%=item.ProductId %>,<%=item.Status== FisheryPlatform.Entity.ProductStatusEnum.Publishing?2:1 %>,'<%=item.CreateDate.ToString() %>')">
                                        <%=item.Status== FisheryPlatform.Entity.ProductStatusEnum.Publishing?"下线":"上线" %></a>&nbsp;|&nbsp;
                                    <a href="javascript:void(0);" onclick="productManager.setStatus(<%=item.ProductId %>,3,'<%=item.CreateDate.ToString() %>')">
                                        删除</a>&nbsp;|&nbsp;<a href="Publish.aspx?proId=<%=item.ProductId %>">修改</a>
                                </td>
                            </tr>
                            <%} %>
                        </table>
                    </div>
                    <div>
                        <ucPB:PageBar runat="server" ID="pb_PageBar" />
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <Menu:Footer runat="server" ID="menuFooter" />
    </div>
</body>
</html>
<script type="text/javascript" src="../Js/Product/Action.js"></script>
<script type="text/javascript">

    function PageChanged(pageIndex) {
        jDoc("txt_PageIndex").value = pageIndex;
        $(jDoc("btn_Search")).click();
    }
    function setDateToInputBy(num, t) {
        var start = new Date();
        var dateFormat = "{0}-{1}-{2}";
        var d = new Date();
        if (t == 0) {
            d.setHours(-num * 24)
        } else {
            var m = d.getMonth();
            m = m - num;
            d.setMonth(m);
        }
        var startString = String.format(dateFormat, d.getFullYear(), d.getMonth() + 1, d.getDate());
        var endString = String.format(dateFormat, start.getFullYear(), start.getMonth() + 1, start.getDate()); ;
        jDoc("txt_StartDate").value = startString;
        jDoc("txt_EndDate").value = endString;
    }
    (function () {
        $("#btn_Search").bind("click"
            , function () {
                var params = [];
                params.push("title=" + encodeURIComponent(jDoc("txt_Title").value));
                params.push("datestart=" + jDoc("txt_StartDate").value);
                params.push("dateend=" + jDoc("txt_EndDate").value);
                params.push("status=" + jDoc("sel_Status").options[jDoc("sel_Status").selectedIndex].value);
                //var orderStatus = jDoc("frm_ddl_orderstatuslist");
                //params.push("orderstatus=" + orderStatus.options[orderStatus.selectedIndex].value);
                //params.push("productname=" + encodeURIComponent(jDoc("frm_txt_productname").value));
                params.push("cateid=" + jDoc("<%= this.pl_Cate.SaveSelectedItemsEleId %>").value);
                params.push("pageIndex=" + jDoc("txt_PageIndex").value);
                params.push("proCode=" + jDoc("txt_ProCode").value);
                //alert(params.join("&"));
                var url = window.location.pathname + "?" + params.join("&");
                window.location.replace(url);
            });
    })();
</script>
